//
//  PhoneRechargeCell.swift
//  Entrance
//
//  Created by Chunhui on 2018/1/31.
//  Copyright © 2018年 chunhuiLai. All rights reserved.
//

import UIKit

class PhoneRechargeHeaderView: UIView {
    
    class var defaultReuseId: String {
        return String(describing: PhoneRechargeSectionHeaderView.self)
    }
    
    lazy var phoneEditField: UITextField = {
        let field = UITextField()
        field.placeholder = "请输入手机号码"
        field.keyboardType = .phonePad
        return field
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        layoutUI()
    }
    
    func layoutUI() {
        addSubview(phoneEditField)
        phoneEditField.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview().offset(20)
            make.top.equalTo(20)
            make.height.equalTo(40)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

//MARK: section header view
class PhoneRechargeSectionHeaderView: UICollectionReusableView {
    
    class var defaultReuseId: String {
        return String(describing: PhoneRechargeSectionHeaderView.self)
    }
    
    lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.textAlignment = .left
        label.textColor = UIColor.init(syHexValue: 0x999999)
        return label
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        layoutUI()
    }
    
    func layoutUI() {
        addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.centerY.equalToSuperview()
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class PhoneRechargeCell: UICollectionViewCell {
    class var defaultReuseId: String {
        return String(describing: PhoneRechargeCell.self)
    }
    
    lazy var backgroundImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage(named: "phoneRecharge_border")
        return imageView
    }()
    
    // 话费价值
    lazy var worthLabel: UILabel = {
        let label = UILabel()
        label.textColor = UIColor.green
        label.font = UIFont.systemFont(ofSize: 14)
        label.textAlignment = .center
        return label
    }()
    
    // 付款价格
    lazy var payPriceLabel: UILabel = {
        let label = UILabel()
        label.textColor = UIColor.green
        label.font = UIFont.systemFont(ofSize: 13)
        label.textAlignment = .center
        return label
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        layoutUI()
    }
    
    func layoutUI() {
        addSubview(backgroundImageView)
        addSubview(worthLabel)
        addSubview(payPriceLabel)
        
        backgroundImageView.snp.makeConstraints { (make) in
            make.top.left.bottom.right.equalToSuperview()
        }
        
        worthLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview().offset(-10)
        }
        
        payPriceLabel.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(worthLabel.snp.bottom).offset(10)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
